package com.wise.wing.activity.logic;


import com.bm.corelibs.logic.BaseLogic;
import com.bm.corelibs.logic.BaseLogic.NListener;
import com.wise.wing.bean.BaseData;
import com.wise.wing.bean.GenericBaseData;
import com.wise.wing.bean.Page;

@SuppressWarnings("rawtypes")
public class BaseManager {
	protected BaseLogic<BaseData> logic = new BaseLogic<BaseData>();
	
	protected BaseLogic<GenericBaseData> genericLogic = new BaseLogic<GenericBaseData>();
	protected Page page = new Page(1, 15, 0);
	protected String token = "";
	
	public void setToken(String token){
		this.token = token;
	}

	public void setPage(Page page) {
		this.page = page;
	}

	public void setMaxPage(int max) {
		page.pageCount = max;
	}

	public int getMaxPage() {
		return page.pageCount;
	}

	public int getCurrentPage() {
		return page.pageNo;
	}
	
	public void getFirst(NListener<BaseData> l) {
		page.pageNo = 1;
		getList(l);
	}

	public void getNext(NListener<BaseData> l) {
		page.pageNo++;
		if(page.pageNo <= page.pageCount)
			getList(l);
		else
			l.onAllPageLoaded(page.pageNo, page.pageCount);
	}
	
	public void getGenericFirst(NListener<GenericBaseData> l) {
		page.pageNo = 1;
		getGenericList(l);
	}

	public void getGenericNext(NListener<GenericBaseData> l) {
		page.pageNo++;
		if(page.pageNo <= page.pageCount)
			getGenericList(l);
		else
			l.onAllPageLoaded(page.pageNo, page.pageCount);
	}
	
	protected void getList(NListener<BaseData> l){};
	protected void getGenericList(final NListener<GenericBaseData> nl){};
}
